<template>
  <div>
    <el-form :model="form" ref="vForm" label-position="left" label-width="80px" size="medium" @submit.native.prevent>
      <div>
        <div class="record-title">抑郁自评量表</div>
      </div>

      <div class="static-content-item-head center">
        <div class="static-content-item">
          <div>姓名：</div>
          <div>{{user.patientName}}</div>
        </div>
        <div class="static-content-item">
          <div>性别：</div>
          <div>{{getGender}}</div>
        </div>
        <div class="static-content-item">
          <div>科室：</div>
          <div>{{user.department}}</div>
        </div>
        <div class="static-content-item">
          <div>床号：</div>
          <div>{{user.bedNum}}</div>
        </div>
        <div class="static-content-item">
          <div>病案号：</div>
          <div>{{user.admissionNum}}</div>
        </div>
      </div>
      <div class="table-container">
        <table class="table-layout center" style="margin-bottom: 30px;">
          <tbody>
            <tr>
              <td class="table-cell">
              </td>
              <td class="table-cell">没有或几乎没有
              </td>
              <td class="table-cell">少有
              </td>
              <td class="table-cell">常有
              </td>
              <td class="table-cell">几乎一直有
              </td>
            </tr>
            <tr v-for="(item,index) in list" :key="index">
              <td class="table-cell">{{index+1}}、{{item.title}}
              </td>
              <td class="table-cell"><el-radio :disabled="disabled" v-model="form[`question${index + 1}Score`]" label="1"></el-radio>
              </td>
              <td class="table-cell"><el-radio :disabled="disabled" v-model="form[`question${index + 1}Score`]" label="2"></el-radio>
              </td>
              <td class="table-cell"><el-radio :disabled="disabled" v-model="form[`question${index + 1}Score`]" label="3"></el-radio>
              </td>
              <td class="table-cell"><el-radio :disabled="disabled" v-model="form[`question${index + 1}Score`]" label="4"></el-radio>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </el-form>
  </div>
</template>
<script>
export default {
  name: '',
  props: {
    user: { type: Object, default: () => ({}) },
    data: { type: Object, default: () => ({}) }
  },
  data() {
    return {
      form: {
        question1Score: null,
        question2Score: null,
        question3Score: null,
        question4Score: null,
        question5Score: null,
        question6Score: null,
        question7Score: null,
        question8Score: null,
        question9Score: null,
        question10Score: null,
        question11Score: null,
        question12Score: null,
        question13Score: null,
        question14Score: null,
        question15Score: null,
        question16Score: null,
        question17Score: null,
        question18Score: null,
        question19Score: null,
        question20Score: null,
      },
      list: []
    }
  },
  created() {
    this.initForm();
    this.setList();
  },
  computed: {
    // 判断用户当前性别
    getGender() {
      switch (this.user.gender) {
        case 0: return "女";
        case 1: return "男";
        default: return null;
      }
    },
    // 判断是否需要禁用
    disabled() {
      return !!this.$route.query.type
    }
  },
  methods: {
    /**
     * 初始化表单数据
     */
    initForm() {
      // this.form = { ...this.form, ...this.data };
      Object.keys(this.form).forEach(key => this.form[key] = `${this.data[key]}`);
    },
    /**
     * 设置列表
     */
    setList() {
      this.list = [
        { title: "我觉得闷闷不乐，情绪低沉" },
        { title: "我觉得一天之中早晨最好" },
        { title: "我一阵阵地哭出来或是想哭" },
        { title: "我晚上睡眠不好" },
        { title: "我吃的和平时一样多" },
        { title: "我与异性接触时和以往一样感到愉快" },
        { title: "我发觉我的体重在下降" },
        { title: "我有便秘的苦恼" },
        { title: "我心跳比平时快" },
        { title: "我无缘无故感到疲乏" },
        { title: "我的头脑和平时一样清楚" },
        { title: "我觉得经常做的事情并没有困难" },
        { title: "我觉得不安而平静不下来" },
        { title: "我对将来抱有希望" },
        { title: "我比平常容易激动" },
        { title: "我觉得做出决定是容易的" },
        { title: "我觉得自己是个有用的人，有人需要我" },
        { title: "我的生活过得很有意思" },
        { title: "我认为如果我死了别人会生活的更好些" },
        { title: "平常感兴趣的事我仍然照样感兴趣" },
      ]
    },
    /**
     * 获取数据
     */
    getForm() {
      return this.form;
    }
  },
}
</script>
<style lang="scss" scoped>
.center {
  width: 80%;
  margin: 0 auto;
}

.record-title {
  font-size: 27px;
  font-weight: bold;
  text-align: center;
  margin: 20px 0;
}

.el-input-number.full-width-input,
.el-cascader.full-width-input {
  width: 100% !important;
}

.clear-fix:before,
.clear-fix:after {
  display: table;
  content: "";
}

.clear-fix:after {
  clear: both;
}

.float-right {
  float: right;
}

div.table-container {
  table.table-layout {
    table-layout: fixed;
    border-collapse: collapse;
    text-align: center;

    td.table-cell {
      display: table-cell;
      height: 38px;
      border: 1px solid #333;
      font-size: 16px;
      overflow-wrap: break-word;
    }
  }
}

tr td:nth-child(1) {
  width: 50%;
  /* 将第一列单元格宽度设置为 50% */
  text-align: left;
  padding-left: 15px;
}

.static-content-item {
  min-height: 20px;
  display: flex;
  align-items: center;
  margin-right: 20px;
  font-size: 16px;

  ::v-deep .el-divider--horizontal {
    margin: 0;
  }
}

.static-content-item-head {
  min-height: 20px;
  font-size: 15px;
  display: flex;
  // justify-content: space-around;
  justify-content: space-between;

  ::v-deep .el-divider--horizontal {
    margin: 0;
  }
}

::v-deep .el-divider--horizontal {
  margin: 0;
}

.el-form-item--small.el-form-item {
  margin-bottom: 0px;
}

::v-deep .el-form-item__label {
  font-size: 16px;
}

.el-form-item {
  margin-bottom: 0px;
}

.footer {
  font-size: 20px;

  input {
    text-align: left;
    width: 40%;
  }
}

//宽度
.w-50 {
  width: 50px;
}

.w-100 {
  width: 100px;
}

.w-150 {
  width: 150px;
}

.w-200 {
  width: 200px;
}

// 去除input样式
input {
  border: none;
  text-align: center;
  width: 100%;
}

input[type="text"]:focus {
  outline: none;
}

input::placeholder {
  color: #ccc;
  /* 设置 placeholder 颜色为灰色 */
}

.textareaStyle {
  width: 100%;
  height: 93%;
  margin-top: 10px;
}

textarea {
  border: none;
  text-align: center;
  width: 100%;
}

textarea[type="text"]:focus {
  outline: none;
}

textarea::placeholder {
  color: #ccc;
  /* 设置 placeholder 颜色为灰色 */
}
</style>
